<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 回调地狱
        // es6 Promise async
        const async1 = async () => {
            console.log('async');
            setTimeout(() => { // event loop 宏任务
                console.log('timer')
            }, 2000)
            await new Promise(resolve => {
                console.log('promise') // resolve没解决
            })
            console.log('script end');
            return 'async1 success';
        }
        console.log('script start');
        async1().then(res => console.log(res))
        console.log('script end')
        Promise.resolve(1) // 静态方法
            .then(2)
            .then(Promise.resolve(3))
            .then(res => console.log(res))

        setTimeout(() => { // 宏任务
            console.log('timer2');
        }, 1000)
    </script>
</body>
</html>